package com.zhku.goods.feignclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class SearchServiceClientFallbackFactory implements FallbackFactory<SearchServiceClient> {
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(GoodsIndex goodsIndex) {
                log.error("添加商品索引发生熔断,索引信息:{},熔断异常:{}", goodsIndex, throwable.toString(), throwable);
                //走降级了返回 false
                return false;
            }

            @Override
            public Boolean update(GoodsIndex goodsIndex) {
                log.error("修改商品索引发生熔断,索引信息:{},熔断异常:{}", goodsIndex, throwable.toString(), throwable);
                //走降级了返回 false
                return false;
            }

            @Override
            public Boolean delete(GoodsIndex goodsIndex) {
                log.error("删除商品索引发生熔断,索引信息:{},熔断异常:{}", goodsIndex, throwable.toString(), throwable);
                //走降级了返回 false
                return false;
            }
        };
    }
}
